Skip to content

fix: React-Native package exports #4887

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

aryaemami59
Copy link
Member

@aryaemami59 aryaemami59 self-assigned this Mar 11, 2025
Copy link

codesandbox bot commented Mar 11, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

codesandbox-ci bot commented Mar 11, 2025

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit f9f283d:

Sandbox Source
@examples-query-react/basic Configuration
@examples-query-react/advanced Configuration
@examples-action-listener/counter Configuration
rtk-esm-cra Configuration

Copy link

netlify bot commented Mar 11, 2025

Deploy Preview for redux-starter-kit-docs ready!

Name Link
🔨 Latest commit f9f283d
🔍 Latest deploy log https://app.netlify.com/sites/redux-starter-kit-docs/deploys/681394f7f93316000830a838
😎 Deploy Preview https://deploy-preview-4887--redux-starter-kit-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@markerikson
Copy link
Collaborator

@aryaemami59 can you summarize the package changes and why they improve things?

@aryaemami59 aryaemami59 force-pushed the fix/react-native-package-exports branch from 2cecb47 to 25f7b50 Compare March 16, 2025 11:06
@aryaemami59 aryaemami59 force-pushed the fix/react-native-package-exports branch from 25f7b50 to c67da92 Compare March 31, 2025 18:22
@aryaemami59 aryaemami59 force-pushed the fix/react-native-package-exports branch from c67da92 to 2ebf48c Compare April 11, 2025 10:07
@aryaemami59 aryaemami59 force-pushed the fix/react-native-package-exports branch from 9de562c to f9f283d Compare May 1, 2025 15:36
@BenQoder
Copy link

BenQoder commented May 2, 2025

This fix is essential, Because in the latest version of Expo (Expo 53); It logs this warning uncountable times.

I hope it is reviewed and merged soon

Copy link
Member

@phryneas phryneas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the tsup changes (was this just a port to TS or bigger changes?) but the exports field changes generally seem reasonable. This should at least be a minor bump, though.

"default": {
"types": "./dist/index.d.ts",
"default": "./dist/cjs/index.js"
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going over one entry point in order here:

  • module-sync is used to enable require(ESM) if supported by the runtime
  • module aims at bundlers
  • react-native, with ESM for import and CJS for require`
  • browser with the ESM browser build
  • import with the ESM build
  • fallback to CJS, will probably only be hit in outdated runtimes that don't support require(ESM)

Seems generally reasonable to me.

@@ -25,27 +25,137 @@
"module": "dist/redux-toolkit.legacy-esm.js",
"main": "dist/cjs/index.js",
"types": "dist/index.d.ts",
"react-native": "dist/redux-toolkit.legacy-esm.js",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On top of that, for RN versions that support ESM, but not exports, pointing at the legacy ESM build.

"types": "./../dist/query/index.d.ts",
"exports": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping the exports field should be okay - a bundler that supports exports should look at the root-level package.json.

@@ -4,16 +4,9 @@
"description": "",
"type": "module",
"module": "../dist/query/rtk-query.legacy-esm.js",
"main": "../dist/query/cjs/index.js",
"main": "./../dist/query/rtk-query.modern.mjs",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here be dragons - this switches from CJS to ESM. Probably be fine, since only outdated bundlers would look at this file at all, but pointing it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Warning with @reduxjs/toolkit/query/react Is this an Expo or RTK issue?
4 participants